﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Besture.Bll;
using Besture.Common;
using Besture.Common.Helper;
using Besture.Model;
using Besture.UI.Common;

namespace Besture.UI.Portal.FindUserPwd
{
    public partial class EmailFindThree : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                UserBaseModel userBaseModel =
                    new UserBaseDac().GetModel(Convert.ToInt32(EncryptHelper.Decrypt(StringHelper.Query("user"))));
                txtEmail.Value = userBaseModel.Email;
            }

        }

          /// <summary>
          /// 修改信息
          /// </summary>
          /// <param name="sender"></param>
          /// <param name="e"></param>
        protected void SaveClick(object sender, EventArgs e)
        {
              try
              { 
                    var cusdac = new UserBaseDac();
                    var cusmodel = new UserBaseModel();
                    cusmodel = cusdac.GetModel(Convert.ToInt32(EncryptHelper.Decrypt(StringHelper.Query("user"))));
                    cusmodel.LoginPwd = StringHelper.GetMD5(newpwd.Value);
                    if (cusdac.Update(cusmodel) > 0)
                    {
                        HttpContext.Current.Session[Constants.SESSION_WEB_USER_MODEL] = null;
                        FunHelper.Alert("修改密码成功！", "/Portal/UserCenter/Login.aspx");
                    } 
              }
              catch
              {
                  FunHelper.Alert("修改密码失败！");
                  // ignored
              }
        }
    }
}